//ResDaP Ajax platform
resdap_ajax_initialized = false;
resdap_ajax_server = "http://resources.scratchr.org/ajax?a=";
function resdap_ajax_init() {
	if (!resdap_ajax_initialized) {
		if (window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp = new XMLHttpRequest();
		} else {
			// code for IE6, IE5
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		resdap_ajax_initialized = true;
	}
}

function resdap_ajax_get(ajaxaction)  {
	//async but direct access in scripts
	resdap_ajax_init()
	xmlhttp.open("GET",resdap_ajax_server+ajaxaction,false);
	xmlhttp.send(null);
	return xmlhttp.responseText;
}
/*
xmlhttp.onreadystatechange=function() {
	currently does nothing
	if(xmlhttp.readyState==4) {
		document.getElementById('test').innerHTML=xmlhttp.responseText
	}
}
*/
//end ajax platform

//ajax apps
function resdap_showresource(id) {
	result = resdap_ajax_get('showresource&id='+id);
	document.location.reload(); //Temporarily
}
function resdap_hideresource(id) {
	result = resdap_ajax_get('hideresource&id='+id);
	document.location.reload(); //Temporarily
}